﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My;
    using ACCOUNTING.My.Resources;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_Login : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("Cancel")]
        private Button _Cancel;
        [AccessedThroughProperty("CboClient")]
        private ComboBox _CboClient;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("OK")]
        private Button _OK;
        [AccessedThroughProperty("OptTiengAnh")]
        private RadioButton _OptTiengAnh;
        [AccessedThroughProperty("OptTiengViet")]
        private RadioButton _OptTiengViet;
        [AccessedThroughProperty("Panel1")]
        private Panel _Panel1;
        [AccessedThroughProperty("Panel2")]
        private Panel _Panel2;
        [AccessedThroughProperty("Panel3")]
        private Panel _Panel3;
        [AccessedThroughProperty("PasswordLabel")]
        private Label _PasswordLabel;
        [AccessedThroughProperty("PasswordTextBox")]
        private TextBox _PasswordTextBox;
        [AccessedThroughProperty("UsernameLabel")]
        private Label _UsernameLabel;
        [AccessedThroughProperty("UsernameTextBox")]
        private TextBox _UsernameTextBox;
        private IContainer components;
        private clsConfig objDK;
        private clsNguoiDung objU;

        public Frm_Login()
        {
            base.HelpRequested += new HelpEventHandler(this.Me_HelpRequested);
            base.KeyDown += new KeyEventHandler(this.Frm_Login_KeyDown);
            base.Load += new EventHandler(this.Frm_Login_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.objU = new clsNguoiDung();
            this.objDK = new clsConfig();
            this.InitializeComponent();
        }

        private void Cancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Frm_Login_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F1)
            {
                LVYModule.ShowHelp(@"QuanLyHeThong\Dang nhap he thong.mht");
            }
        }

        private void Frm_Login_Load(object sender, EventArgs e)
        {
            if (LVYModule.ReturnIfNull(modGeneral.ConnectionString, "", modGeneral.TypeOfValue.Nothing).ToString().Trim() == "")
            {
                LVYModule.ShowWarning("You have to setting connections to database");
                this.Dispose();
            }
            else
            {
                BuildComboModule.BuildCombo(this.CboClient, modGeneral.ListDanhMuc.DonVi, false, "", "");
                string str = Interaction.GetSetting(modGeneral.H_KEYAPPNAME, "CLIENT", "CLIENTKEY", "");
                this.CboClient.SelectedValue = str;
                if (modGeneral.H_LANGUAGE == "VIET")
                {
                    this.OptTiengViet.Checked = true;
                }
                else
                {
                    this.OptTiengAnh.Checked = true;
                }
            }

            SetEvents();
        }

        private void GroupBox1_Enter(object sender, EventArgs e)
        {
        }

        [DllImport("hhctrl.ocx")]
        private static extern bool HtmlHelp(IntPtr handle, string file, int command, int data);
        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            this._Cancel = new System.Windows.Forms.Button();
            this._OK = new System.Windows.Forms.Button();
            this._OptTiengAnh = new System.Windows.Forms.RadioButton();
            this._OptTiengViet = new System.Windows.Forms.RadioButton();
            this._Label1 = new System.Windows.Forms.Label();
            this._CboClient = new System.Windows.Forms.ComboBox();
            this._PasswordTextBox = new System.Windows.Forms.TextBox();
            this._UsernameTextBox = new System.Windows.Forms.TextBox();
            this._PasswordLabel = new System.Windows.Forms.Label();
            this._UsernameLabel = new System.Windows.Forms.Label();
            this._Panel2 = new System.Windows.Forms.Panel();
            this._Panel3 = new System.Windows.Forms.Panel();
            this._Panel1 = new System.Windows.Forms.Panel();
            this._Panel2.SuspendLayout();
            this._Panel3.SuspendLayout();
            this.SuspendLayout();
            // 
            // _Cancel
            // 
            this._Cancel.BackColor = System.Drawing.Color.Transparent;
            this._Cancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this._Cancel.Location = new System.Drawing.Point(307, 3);
            this._Cancel.Name = "_Cancel";
            this._Cancel.Size = new System.Drawing.Size(78, 25);
            this._Cancel.TabIndex = 1;
            this._Cancel.Text = "&Thoát";
            this._Cancel.UseVisualStyleBackColor = false;
            // 
            // _OK
            // 
            this._OK.BackColor = System.Drawing.Color.Transparent;
            this._OK.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this._OK.Location = new System.Drawing.Point(220, 3);
            this._OK.Name = "_OK";
            this._OK.Size = new System.Drawing.Size(76, 25);
            this._OK.TabIndex = 0;
            this._OK.Text = "&Chọn";
            this._OK.UseVisualStyleBackColor = false;
            // 
            // _OptTiengAnh
            // 
            this._OptTiengAnh.AutoSize = true;
            this._OptTiengAnh.BackColor = System.Drawing.Color.Transparent;
            this._OptTiengAnh.Location = new System.Drawing.Point(242, 131);
            this._OptTiengAnh.Name = "_OptTiengAnh";
            this._OptTiengAnh.Size = new System.Drawing.Size(74, 17);
            this._OptTiengAnh.TabIndex = 7;
            this._OptTiengAnh.Text = "&Tiếng Anh";
            this._OptTiengAnh.UseVisualStyleBackColor = false;
            this._OptTiengAnh.Visible = false;
            // 
            // _OptTiengViet
            // 
            this._OptTiengViet.AutoSize = true;
            this._OptTiengViet.BackColor = System.Drawing.Color.Transparent;
            this._OptTiengViet.Checked = true;
            this._OptTiengViet.Location = new System.Drawing.Point(137, 131);
            this._OptTiengViet.Name = "_OptTiengViet";
            this._OptTiengViet.Size = new System.Drawing.Size(73, 17);
            this._OptTiengViet.TabIndex = 6;
            this._OptTiengViet.TabStop = true;
            this._OptTiengViet.Text = "Tiếng &Việt";
            this._OptTiengViet.UseVisualStyleBackColor = false;
            this._OptTiengViet.Visible = false;
            // 
            // _Label1
            // 
            this._Label1.AutoSize = true;
            this._Label1.BackColor = System.Drawing.Color.Transparent;
            this._Label1.Location = new System.Drawing.Point(25, 71);
            this._Label1.Name = "_Label1";
            this._Label1.Size = new System.Drawing.Size(38, 13);
            this._Label1.TabIndex = 4;
            this._Label1.Text = "Đơn vị";
            this._Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // _CboClient
            // 
            this._CboClient.FormattingEnabled = true;
            this._CboClient.Location = new System.Drawing.Point(137, 68);
            this._CboClient.Name = "_CboClient";
            this._CboClient.Size = new System.Drawing.Size(248, 21);
            this._CboClient.TabIndex = 5;
            // 
            // _PasswordTextBox
            // 
            this._PasswordTextBox.Location = new System.Drawing.Point(137, 40);
            this._PasswordTextBox.Name = "_PasswordTextBox";
            this._PasswordTextBox.PasswordChar = '*';
            this._PasswordTextBox.Size = new System.Drawing.Size(248, 20);
            this._PasswordTextBox.TabIndex = 3;
            // 
            // _UsernameTextBox
            // 
            this._UsernameTextBox.Location = new System.Drawing.Point(137, 13);
            this._UsernameTextBox.Name = "_UsernameTextBox";
            this._UsernameTextBox.Size = new System.Drawing.Size(248, 20);
            this._UsernameTextBox.TabIndex = 1;
            // 
            // _PasswordLabel
            // 
            this._PasswordLabel.AutoSize = true;
            this._PasswordLabel.BackColor = System.Drawing.Color.Transparent;
            this._PasswordLabel.Location = new System.Drawing.Point(25, 43);
            this._PasswordLabel.Name = "_PasswordLabel";
            this._PasswordLabel.Size = new System.Drawing.Size(52, 13);
            this._PasswordLabel.TabIndex = 2;
            this._PasswordLabel.Text = "Mật khẩu";
            this._PasswordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // _UsernameLabel
            // 
            this._UsernameLabel.AutoSize = true;
            this._UsernameLabel.BackColor = System.Drawing.Color.Transparent;
            this._UsernameLabel.Location = new System.Drawing.Point(25, 16);
            this._UsernameLabel.Name = "_UsernameLabel";
            this._UsernameLabel.Size = new System.Drawing.Size(81, 13);
            this._UsernameLabel.TabIndex = 0;
            this._UsernameLabel.Text = "Tên đăng nhập";
            this._UsernameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // _Panel2
            // 
            this._Panel2.BackColor = System.Drawing.Color.PaleTurquoise;
            this._Panel2.Controls.Add(this._OK);
            this._Panel2.Controls.Add(this._Cancel);
            this._Panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
            this._Panel2.Location = new System.Drawing.Point(0, 248);
            this._Panel2.Name = "_Panel2";
            this._Panel2.Size = new System.Drawing.Size(401, 32);
            this._Panel2.TabIndex = 1;
            // 
            // _Panel3
            // 
            this._Panel3.BackColor = System.Drawing.Color.PaleTurquoise;
            this._Panel3.Controls.Add(this._UsernameTextBox);
            this._Panel3.Controls.Add(this._UsernameLabel);
            this._Panel3.Controls.Add(this._PasswordLabel);
            this._Panel3.Controls.Add(this._OptTiengAnh);
            this._Panel3.Controls.Add(this._PasswordTextBox);
            this._Panel3.Controls.Add(this._OptTiengViet);
            this._Panel3.Controls.Add(this._CboClient);
            this._Panel3.Controls.Add(this._Label1);
            this._Panel3.Dock = System.Windows.Forms.DockStyle.Fill;
            this._Panel3.Location = new System.Drawing.Point(0, 142);
            this._Panel3.Name = "_Panel3";
            this._Panel3.Size = new System.Drawing.Size(401, 106);
            this._Panel3.TabIndex = 0;
            // 
            // _Panel1
            // 
            this._Panel1.BackgroundImage = global::Properties.Resources.dangnhap;
            this._Panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
            this._Panel1.Dock = System.Windows.Forms.DockStyle.Top;
            this._Panel1.Location = new System.Drawing.Point(0, 0);
            this._Panel1.Name = "_Panel1";
            this._Panel1.Size = new System.Drawing.Size(401, 142);
            this._Panel1.TabIndex = 2;
            // 
            // Frm_Login
            // 
            this.AcceptButton = this._OK;
            this.BackColor = System.Drawing.Color.White;
            this.ClientSize = new System.Drawing.Size(401, 280);
            this.ControlBox = false;
            this.Controls.Add(this._Panel3);
            this.Controls.Add(this._Panel2);
            this.Controls.Add(this._Panel1);
            this.KeyPreview = true;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "Frm_Login";
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "DANG NHAP HE THONG";
            this._Panel2.ResumeLayout(false);
            this._Panel3.ResumeLayout(false);
            this._Panel3.PerformLayout();
            this.ResumeLayout(false);

        }

        private void Me_HelpRequested(object sender, HelpEventArgs hlpevent)
        {
            HtmlHelp(this.Handle, "Dragon_Help.chm", 15, 1);
        }

        private void OK_Click(object sender, EventArgs e)
        {
            if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboClient.SelectedValue), "", modGeneral.TypeOfValue.Nothing).ToString().Trim() == "")
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn phải chọn đơn vị sử dụng!", ""));
                this.CboClient.Focus();
            }
            else if (!this.objU.CheckIvalid(this.UsernameTextBox.Text, this.PasswordTextBox.Text))
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("T\x00ean người d\x00f9ng v\x00e0 mật khẩu kh\x00f4ng hợp lệ!", ""));
                this.UsernameTextBox.Focus();
            }
            else
            {
                modGeneral.H_USERID = this.objU.KhoaNhanVien;
                modGeneral.H_USERNAME = this.objU.TenDangNhap;
                modGeneral.H_GIOIHANDULIEU = this.objU.GioiHanDuLieu > 0;
                if (this.objU.KhoaNhanVien != "000000000000000")
                {
                    if (this.OptTiengViet.Checked)
                    {
                        modGeneral.H_EMPLOYEE = this.objU.TenViet;
                    }
                    else
                    {
                        modGeneral.H_EMPLOYEE = this.objU.TenAnh;
                    }
                }
                else
                {
                    modGeneral.H_EMPLOYEE = this.objU.TenDangNhap;
                }
                if (this.OptTiengViet.Checked)
                {
                    Interaction.SaveSetting(modGeneral.H_KEYAPPNAME, "LANGUAGE", "LANG", "VIET");
                    modGeneral.H_LANGUAGE = "VIET";
                }
                else
                {
                    Interaction.SaveSetting(modGeneral.H_KEYAPPNAME, "LANGUAGE", "LANG", "ANH");
                    modGeneral.H_LANGUAGE = "ANH";
                }
                Interaction.SaveSetting(modGeneral.H_KEYAPPNAME, "CLIENT", "CLIENTKEY", LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboClient.SelectedValue), "", modGeneral.TypeOfValue.Nothing).ToString());
                clsDMDonVi vi = new clsDMDonVi();
                vi.Load(Conversions.ToString(this.CboClient.SelectedValue));
                modGeneral.H_PREFIX = vi.Prefix;
                modGeneral.H_CLIENT = vi.Khoa;
                modGeneral.H_USERTYPE = this.objU.LoaiNguoiDung;
                if (vi.Prefix != "TT")
                {
                    modGeneral.H_ISCLIENT = 1;
                }
                else
                {
                    modGeneral.H_ISCLIENT = 0;
                }
                this.objU.LoggedIn(this.objU.TenDangNhap, 1);
                this.objDK.Load();
                if (Operators.ConditionalCompareObjectEqual(LVYModule.ReturnIfNull(this.objDK.DaNhapTTCT, 0, modGeneral.TypeOfValue.Nothing), 0, false) && (this.objU.KhoaNhanVien == "000000000000000"))
                {
                    MyProject.Forms.Frm_ThongTinCongTy.Dispose();
                    MyProject.Forms.Frm_ThongTinCongTy.ShowDialog();
                    MyProject.Forms.Frm_ThongTinCongTy.BringToFront();
                }
                if (Operators.ConditionalCompareObjectEqual(LVYModule.ReturnIfNull(this.objDK.LoaiHoaDonInMacDinh, "", modGeneral.TypeOfValue.Nothing), "", false))
                {
                    if (this.objU.KhoaNhanVien != "000000000000000")
                    {
                        LVYModule.ShowWarning("T\x00f9y chọn in h\x00f3a đơn chưa được người quản trị thiết lập !");
                        Application.Exit();
                    }
                    else
                    {
                        MyProject.Forms.Frm_ThietLapHoaDon.Dispose();
                        if (MyProject.Forms.Frm_ThietLapHoaDon.ShowDialog() != DialogResult.OK)
                        {
                            Application.Exit();
                        }
                    }
                }
                this.Dispose();
            }
        }

        public void SetEvents()
        {
            this._Cancel.Click += this.Cancel_Click;
            this._OK.Click += this.OK_Click;
        }

        internal virtual Button Cancel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Cancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.Cancel_Click);
                if (this._Cancel != null)
                {
                    this._Cancel.Click -= handler;
                }
                this._Cancel = value;
                if (this._Cancel != null)
                {
                    this._Cancel.Click += handler;
                }
            }
        }

        internal virtual ComboBox CboClient
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboClient;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CboClient = value;
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Button OK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._OK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.OK_Click);
                if (this._OK != null)
                {
                    this._OK.Click -= handler;
                }
                this._OK = value;
                if (this._OK != null)
                {
                    this._OK.Click += handler;
                }
            }
        }

        internal virtual RadioButton OptTiengAnh
        {
            [DebuggerNonUserCode]
            get
            {
                return this._OptTiengAnh;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._OptTiengAnh = value;
            }
        }

        internal virtual RadioButton OptTiengViet
        {
            [DebuggerNonUserCode]
            get
            {
                return this._OptTiengViet;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._OptTiengViet = value;
            }
        }

        internal virtual Panel Panel1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel1 = value;
            }
        }

        internal virtual Panel Panel2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel2 = value;
            }
        }

        internal virtual Panel Panel3
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel3;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel3 = value;
            }
        }

        internal virtual Label PasswordLabel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._PasswordLabel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._PasswordLabel = value;
            }
        }

        internal virtual TextBox PasswordTextBox
        {
            [DebuggerNonUserCode]
            get
            {
                return this._PasswordTextBox;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._PasswordTextBox = value;
            }
        }

        internal virtual Label UsernameLabel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._UsernameLabel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._UsernameLabel = value;
            }
        }

        internal virtual TextBox UsernameTextBox
        {
            [DebuggerNonUserCode]
            get
            {
                return this._UsernameTextBox;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._UsernameTextBox = value;
            }
        }
    }
}

